package cn.craftyun.serverlist.service.impl;

import cn.craftyun.serverlist.entity.Server;
import cn.craftyun.serverlist.mapper.ServerMapper;
import cn.craftyun.serverlist.param.ListServerParam;
import cn.craftyun.serverlist.service.IServerService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Arrays;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author FanHuaCloud
 * @since 2021-09-22
 */
@Service
public class ServerServiceImpl extends ServiceImpl<ServerMapper, Server> implements IServerService {
    /**
     * 获取服务器列表
     *
     * @param page  分页参数
     * @param param 筛选参数
     * @return 服务器分页对象
     */
    @Override
    public IPage<Server> selectPageByUser(IPage<Server> page, ListServerParam param) {
        IPage<Server> serverIPage = getBaseMapper().selectPageByUser(page, param);
        serverIPage.getRecords().forEach(server -> server.setImgFulls(Arrays.asList(server.getImgFull().split(","))));
        return serverIPage;
    }
}
